<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="搬砖 嵌入式">
<meta property="og:type" content="website">
<meta property="og:title" content="学无止境">
<meta property="og:url" content="http://example.com/page/22/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="搬砖 嵌入式">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="xudonglei">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/page/22/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/08/01/Jetson%20nano%E4%B8%8Amcp2515%E6%80%80%E7%96%91%E4%B8%AD%E6%96%AD%E5%BC%95%E8%84%9A%E7%9A%84%E9%97%AE%E9%A2%98/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/08/01/Jetson%20nano%E4%B8%8Amcp2515%E6%80%80%E7%96%91%E4%B8%AD%E6%96%AD%E5%BC%95%E8%84%9A%E7%9A%84%E9%97%AE%E9%A2%98/" class="post-title-link" itemprop="url">Jetson nano上mcp2515怀疑中断引脚的问题</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-08-01 09:45:16" itemprop="dateCreated datePublished" datetime="2021-08-01T09:45:16+08:00">2021-08-01</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jetson/" itemprop="url" rel="index"><span itemprop="name">Jetson</span></a>
                </span>
            </span>

          
            <span id="/2021/08/01/Jetson%20nano%E4%B8%8Amcp2515%E6%80%80%E7%96%91%E4%B8%AD%E6%96%AD%E5%BC%95%E8%84%9A%E7%9A%84%E9%97%AE%E9%A2%98/" class="post-meta-item leancloud_visitors" data-flag-title="Jetson nano上mcp2515怀疑中断引脚的问题" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/08/01/Jetson%20nano%E4%B8%8Amcp2515%E6%80%80%E7%96%91%E4%B8%AD%E6%96%AD%E5%BC%95%E8%84%9A%E7%9A%84%E9%97%AE%E9%A2%98/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/08/01/Jetson%20nano%E4%B8%8Amcp2515%E6%80%80%E7%96%91%E4%B8%AD%E6%96%AD%E5%BC%95%E8%84%9A%E7%9A%84%E9%97%AE%E9%A2%98/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    nvidia官方的开发者原话是这么说的：For people who are facing issues with send/receive, It looks like the issue with interrupts. 他怀疑是中断引脚的问题，所以他建议可以做一个试验，</p>
<p>​    因为在jetpack 4.5中，第一路spi使用了中断引脚Pin31，我们需要先执行下面这两行指令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo ip link set can0 type can bitrate 500000 loopback on</span><br><span class="line">sudo ip link set up can0</span><br></pre></td></tr></table></figure>
<p>上面执行之后再执行：cat  /proc/interrupts |  grep mcp</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210523204019.png"></p>
<p>这里GPIO200其实就是PIN31:</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210523204613.png"></p>
<p>根据Jetson Nano IO物理引脚与虚拟引脚映射计算，#define TEGRA_GPIO_BANK_ID_Z 25，再用公式可得：25*8=200。</p>
<p>​    知道了mcp2515使用的中断引脚之后，我们再另外找一个引脚，把它配置成输出，还要把这个引脚和PIN31短接，然后翻转这个引脚，再用cat  /proc/interrupts |  grep mcp指令看中断数有没有增加。下面是翻转PIN15的python代码：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> Jetson.GPIO <span class="keyword">as</span> GPIO</span><br><span class="line"><span class="keyword">import</span> time</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&#x27;__main__&#x27;</span>:</span><br><span class="line">	LED = <span class="number">22</span></span><br><span class="line">	GPIO.setmode(GPIO.BCM)</span><br><span class="line">	GPIO.setup(LED, GPIO.OUT)</span><br><span class="line"></span><br><span class="line">	<span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">		GPIO.output(LED, GPIO.HIGH)</span><br><span class="line">		time.sleep(<span class="number">2</span>)</span><br><span class="line">		GPIO.output(LED, GPIO.LOW)</span><br><span class="line">		time.sleep(<span class="number">2</span>)</span><br><span class="line">	GPIO.cleanup(LED)</span><br></pre></td></tr></table></figure>
<p>让python代码不断运行，然后我们用cat  /proc/interrupts |  grep mcp看中断数有没有增加：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210523210318.png"></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/07/09/python%E5%A4%84%E7%90%86excel%E6%96%87%E4%BB%B6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/07/09/python%E5%A4%84%E7%90%86excel%E6%96%87%E4%BB%B6/" class="post-title-link" itemprop="url">python处理excel文件</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-07-09 16:22:32" itemprop="dateCreated datePublished" datetime="2021-07-09T16:22:32+08:00">2021-07-09</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
                </span>
            </span>

          
            <span id="/2021/07/09/python%E5%A4%84%E7%90%86excel%E6%96%87%E4%BB%B6/" class="post-meta-item leancloud_visitors" data-flag-title="python处理excel文件" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/07/09/python%E5%A4%84%E7%90%86excel%E6%96%87%E4%BB%B6/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/07/09/python%E5%A4%84%E7%90%86excel%E6%96%87%E4%BB%B6/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    本文内容来自于网络，原文地址：<a target="_blank" rel="noopener" href="http://www.zzvips.com/article/92089.html">http://www.zzvips.com/article/92089.html</a></p>
<h3 id="1-读取excel文件"><a href="#1-读取excel文件" class="headerlink" title="1. 读取excel文件"></a>1. 读取excel文件</h3><p>​    使用第三方模块库xlrd</p>
<p>例子：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210709154246.png" style="zoom:60%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210709154523.png" style="zoom:70%;">

<h3 id="2-生成excel文件"><a href="#2-生成excel文件" class="headerlink" title="2. 生成excel文件"></a>2. 生成excel文件</h3><p>​    用xlrd读取excel是不能对其进行操作的；而xlwt生成excel文件是不能在已有的excel文件基础上进行修改的。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210709160225.png" style="zoom:60%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210709160340.png" style="zoom:60%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210709160350.png" style="zoom:67%;">

<h3 id="3-修改已有的excel文件"><a href="#3-修改已有的excel文件" class="headerlink" title="3. 修改已有的excel文件"></a>3. 修改已有的excel文件</h3><p>​    如需要修改文件就要使用xluntils模块。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210709161850.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210709162008.png" style="zoom:67%;">
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/07/04/CYUSB3KIT-003%20EZ-USB%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/07/04/CYUSB3KIT-003%20EZ-USB%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85/" class="post-title-link" itemprop="url">CYUSB3KIT-003 EZ-USB开发环境安装</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-07-04 21:41:49" itemprop="dateCreated datePublished" datetime="2021-07-04T21:41:49+08:00">2021-07-04</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2021/07/04/CYUSB3KIT-003%20EZ-USB%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85/" class="post-meta-item leancloud_visitors" data-flag-title="CYUSB3KIT-003 EZ-USB开发环境安装" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/07/04/CYUSB3KIT-003%20EZ-USB%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/07/04/CYUSB3KIT-003%20EZ-USB%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h3 id="1-软件安装"><a href="#1-软件安装" class="headerlink" title="1. 软件安装"></a>1. 软件安装</h3><p>​    去网址：<a target="_blank" rel="noopener" href="https://china.cypress.com/documentation/development-kitsboards/cyusb3kit-003-ez-usb-fx3-superspeed-explorer-kit">https://china.cypress.com/documentation/development-kitsboards/cyusb3kit-003-ez-usb-fx3-superspeed-explorer-kit</a> 下载SuperSpeedExplorerKitSetup_RevSS.exe安装。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210704195401.png" style="zoom:50%;">

<p>安装完成后文件夹如下图所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210704200034.png" style="zoom:50%;">

<h3 id="2-示例固件导入IDE"><a href="#2-示例固件导入IDE" class="headerlink" title="2. 示例固件导入IDE"></a>2. 示例固件导入IDE</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210704200605.png" style="zoom:50%;">

<p>​    打开这个IDE的时候，报错了，如下所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210704200756.png" style="zoom:50%;">

<p>​    出现这个问题的原因是：Cypress的EZ USB Suit估计是32位的eclipse，而我电脑里的JDK原来安装的是64位的，启动不起来，因此要重新装了下32位的JDK。下载JDK安装包，到官网<a target="_blank" rel="noopener" href="http://www.oracle.com/technetwork/java/javase/downloads/index.html%E8%BF%9B%E8%A1%8C%E4%B8%8B%E8%BD%BD%E3%80%82%E5%9B%A0%E4%B8%BA%E8%A6%81%E4%B8%8B%E8%BD%BD32%E4%BD%8D%E7%9A%84jdk%EF%BC%8C%E5%9B%A0%E6%AD%A4%E4%B8%8B%E8%BD%BD%E4%B8%8B%E9%9D%A2%E8%BF%99%E4%B8%AA%E7%89%88%E6%9C%AC%E7%9A%84%EF%BC%8C%E5%A4%AA%E9%AB%98%E7%9A%84%E7%89%88%E6%9C%AC%E7%9A%84%E8%AF%9D%E4%B8%8D%E6%8F%90%E4%BE%9B32%E4%BD%8D%E7%9A%84%E3%80%82">http://www.oracle.com/technetwork/java/javase/downloads/index.html进行下载。因为要下载32位的jdk，因此下载下面这个版本的，太高的版本的话不提供32位的。</a></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210704202241.png" style="zoom:50%;">

<p>下载安装成功后就可以打开IDE了，然后依次选择 <strong>File</strong> &gt; <strong>Import</strong>，选择 <strong>General</strong> &gt; <strong>Existing Projects into Workspace</strong>，然后点击 <strong>Next</strong>。 点击 <strong>Browse…</strong>按钮，然后导航到 Cypress SDK firmware文件夹，该文件夹位于：D:\Pro_Software\Cypress\EZ-USB FX3 SDK\1.3\firmware</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210704204308.png" style="zoom:50%;">

<p>勾选你想用的赛普拉斯范例项目(比如USBBulkSourceSink)，同样，可以选中Copy projects into  workspace，然后点击 Finish 按键。</p>
<h3 id="3-编译并下载程序"><a href="#3-编译并下载程序" class="headerlink" title="3. 编译并下载程序"></a>3. 编译并下载程序</h3><p>​    把cyusb3014的官方开发板连接到电脑上，设备管理器里显示WestBridge，这样的话无法下载程序。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210704211211.png"></p>
<p>在这个设备上右击更新驱动程序，选择浏览我的电脑以查找驱动程序，D:\Pro_Software\Cypress\SuperSpeed Explorer Kit\1.0\Driver\bin，这样自动安装之后就正常显示为bootloader设备了。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210704212524.png" style="zoom:50%;">

<p>之后用USB Control Center将上面选的那个示例固件下载到开发板的ram里面。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210704213038.png" style="zoom:60%;">

<h3 id="4-上位机测试"><a href="#4-上位机测试" class="headerlink" title="4. 上位机测试"></a>4. 上位机测试</h3><p>​    打开D:\Pro_Software\Cypress\EZ-USB FX3 SDK\1.3\application\cpp\streamer\x86\Release\Streamer.exe，运行它就可以了。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210704213800.png" style="zoom:50%;">
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/06/30/Jetson%20Xavier%20NX%E9%80%9A%E8%BF%87sdmmc3%E4%BD%BF%E7%94%A8sd%20card/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/06/30/Jetson%20Xavier%20NX%E9%80%9A%E8%BF%87sdmmc3%E4%BD%BF%E7%94%A8sd%20card/" class="post-title-link" itemprop="url">Jetson Xavier NX通过sdmmc3使用sd card</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-06-30 09:22:37" itemprop="dateCreated datePublished" datetime="2021-06-30T09:22:37+08:00">2021-06-30</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jetson/" itemprop="url" rel="index"><span itemprop="name">Jetson</span></a>
                </span>
            </span>

          
            <span id="/2021/06/30/Jetson%20Xavier%20NX%E9%80%9A%E8%BF%87sdmmc3%E4%BD%BF%E7%94%A8sd%20card/" class="post-meta-item leancloud_visitors" data-flag-title="Jetson Xavier NX通过sdmmc3使用sd card" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/06/30/Jetson%20Xavier%20NX%E9%80%9A%E8%BF%87sdmmc3%E4%BD%BF%E7%94%A8sd%20card/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/06/30/Jetson%20Xavier%20NX%E9%80%9A%E8%BF%87sdmmc3%E4%BD%BF%E7%94%A8sd%20card/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          Here's something encrypted, password is required to continue reading.
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2021/06/30/Jetson%20Xavier%20NX%E9%80%9A%E8%BF%87sdmmc3%E4%BD%BF%E7%94%A8sd%20card/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/06/21/Jetson%20Xavier%20NX%20emmc%E5%88%B7%E6%9C%BA/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/06/21/Jetson%20Xavier%20NX%20emmc%E5%88%B7%E6%9C%BA/" class="post-title-link" itemprop="url">Jetson Xavier NX emmc刷机</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-06-21 19:01:51" itemprop="dateCreated datePublished" datetime="2021-06-21T19:01:51+08:00">2021-06-21</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jetson/" itemprop="url" rel="index"><span itemprop="name">Jetson</span></a>
                </span>
            </span>

          
            <span id="/2021/06/21/Jetson%20Xavier%20NX%20emmc%E5%88%B7%E6%9C%BA/" class="post-meta-item leancloud_visitors" data-flag-title="Jetson Xavier NX emmc刷机" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/06/21/Jetson%20Xavier%20NX%20emmc%E5%88%B7%E6%9C%BA/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/06/21/Jetson%20Xavier%20NX%20emmc%E5%88%B7%E6%9C%BA/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    本文来自于网络，原地址：<a target="_blank" rel="noopener" href="https://blog.csdn.net/u014531804/article/details/108684128%E3%80%82%E6%8C%89%E7%85%A7%E8%AF%A5%E6%96%87%E7%AB%A0%E4%B8%AD%E7%9A%84%E6%AD%A5%E9%AA%A4%EF%BC%8C%E5%8F%AF%E4%BB%A5%E6%88%90%E5%8A%9F%E7%9A%84%E5%B0%86Jetson">https://blog.csdn.net/u014531804/article/details/108684128。按照该文章中的步骤，可以成功的将Jetson</a> Xavier NX的系统镜像烧写到emmc中。</p>
<h3 id="1-官网固件下载"><a href="#1-官网固件下载" class="headerlink" title="1.官网固件下载"></a>1.官网固件下载</h3><p>​    英伟达官网L4T下载页面给出了系列的开发下载资源(<a target="_blank" rel="noopener" href="https://developer.nvidia.com/zh-cn/embedded/downloads)%E3%80%82">https://developer.nvidia.com/zh-cn/embedded/downloads)。</a></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210621170922.png" style="zoom:67%;">



<p>​    对于 Jetson Xavier NX 系统烧录，我们需要下载两个：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210621171616.png" style="zoom:67%;">

<p>​    （1）Sample Root Filesystem</p>
<p>​              对应文件：Tegra_Linux_Sample-Root-Filesystem_R32.5.1_aarch64.tbz2</p>
<p>​      (2)  L4T Driver Package (BSP)</p>
<p>​             对应文件：Tegra186_Linux_R32.5.1_aarch64.tbz2</p>
<h3 id="2-安装qemu"><a href="#2-安装qemu" class="headerlink" title="2. 安装qemu"></a>2. 安装qemu</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install qemu-user-static</span><br></pre></td></tr></table></figure>
<h3 id="3-解压固件并构建文件系统"><a href="#3-解压固件并构建文件系统" class="headerlink" title="3.解压固件并构建文件系统"></a>3.解压固件并构建文件系统</h3><p>​    (1) 在电脑上建立一个自己的工作目录：mkdir nx</p>
<p>​    (2) 拷贝下载的固件到工作目录/nx下</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ls</span><br><span class="line">Tegra186_Linux_R32.5.1_aarch64.tbz2   Tegra_Linux_Sample-Root-Filesystem_R32.5.1_aarch64.tbz2</span><br></pre></td></tr></table></figure>
<p>​    (3) 解压bsp，并构建文件系统</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">tar xf Tegra186_Linux_R32.5.1_aarch64.tbz2</span><br><span class="line">ls</span><br><span class="line"></span><br><span class="line">cd Linux_for_Tegra/rootfs/</span><br><span class="line">sudo tar xpf ../../Tegra_Linux_Sample-Root-Filesystem_R32.5.1_aarch64.tbz2</span><br></pre></td></tr></table></figure>
<p>​    (4) 执行 apply_binaries.sh</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">cd ..</span><br><span class="line">sudo ./apply_binaries.sh</span><br><span class="line"></span><br><span class="line">等待执行结果，最后会有个打印：</span><br><span class="line">Installing extlinux.conf into /boot/extlinux in target rootfs</span><br><span class="line">Success!</span><br></pre></td></tr></table></figure>
<p>完成以上所有步骤就可以准备烧录了。</p>
<h3 id="4-烧录系统"><a href="#4-烧录系统" class="headerlink" title="4. 烧录系统"></a>4. 烧录系统</h3><p>​    Jetson Xavier NX 当前市场上拿到的emmc版本对应如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Module Part Number：Jetson Xavier NX P3668-0001</span><br><span class="line">Value of $(BOARD)：  p3449-0000+p3668-0001-qspi-emmc </span><br></pre></td></tr></table></figure>
<p>​    使用usb连接线连接 虚拟机 和 Jetson Xavier NX，在核心板下方有个名为 “FC_REC” 的引脚 ，其可以控制系统上电后进入recovery模式，使用杜邦线或者跳线帽将其和相邻的GND引脚短接。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210621185041.png" style="zoom:50%;">

<p>​    在虚拟机环境下输入lsusb命令，可以查看到：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Bus 003 Device 054: ID 0955:7020 NVidia Corp.      &lt;---------- 这里就是 nx板子</span><br></pre></td></tr></table></figure>
<p>​    执行烧录命令:</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo ./flash.sh p3449-0000+p3668-0001-qspi-emmc mmcblk0p1</span><br></pre></td></tr></table></figure>
<p>​    接下来耐心等待，大约10分钟，系统会自动擦除emmc，并将固件写入。</p>
<p>​    最后可以观察到如下打印：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">...</span><br><span class="line">*** The target t186ref has been flashed successfully. ***</span><br><span class="line">Reset the board to boot from internal eMMC.</span><br></pre></td></tr></table></figure>
<p>​    将 “FC_REC” 引脚和GND短接的线去掉，拔掉 DC5V，重新上电，接上HDMI和鼠标键盘。系统会自动进入配置页面，要求接受一些协议，初始化用户名什么的，正常配置下即可。之后就可以正常使用系统了。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/06/15/%E7%94%B5%E5%B9%B3%E8%BD%AC%E6%8D%A2%E5%99%A8%E9%80%A0%E6%88%90GPS%E6%A8%A1%E5%9D%97%E6%97%A0%E8%BE%93%E5%87%BA/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/06/15/%E7%94%B5%E5%B9%B3%E8%BD%AC%E6%8D%A2%E5%99%A8%E9%80%A0%E6%88%90GPS%E6%A8%A1%E5%9D%97%E6%97%A0%E8%BE%93%E5%87%BA/" class="post-title-link" itemprop="url">电平转换器造成GPS模块无输出</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-06-15 19:41:15" itemprop="dateCreated datePublished" datetime="2021-06-15T19:41:15+08:00">2021-06-15</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2021/06/15/%E7%94%B5%E5%B9%B3%E8%BD%AC%E6%8D%A2%E5%99%A8%E9%80%A0%E6%88%90GPS%E6%A8%A1%E5%9D%97%E6%97%A0%E8%BE%93%E5%87%BA/" class="post-meta-item leancloud_visitors" data-flag-title="电平转换器造成GPS模块无输出" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/06/15/%E7%94%B5%E5%B9%B3%E8%BD%AC%E6%8D%A2%E5%99%A8%E9%80%A0%E6%88%90GPS%E6%A8%A1%E5%9D%97%E6%97%A0%E8%BE%93%E5%87%BA/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/06/15/%E7%94%B5%E5%B9%B3%E8%BD%AC%E6%8D%A2%E5%99%A8%E9%80%A0%E6%88%90GPS%E6%A8%A1%E5%9D%97%E6%97%A0%E8%BE%93%E5%87%BA/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          Here's something encrypted, password is required to continue reading.
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2021/06/15/%E7%94%B5%E5%B9%B3%E8%BD%AC%E6%8D%A2%E5%99%A8%E9%80%A0%E6%88%90GPS%E6%A8%A1%E5%9D%97%E6%97%A0%E8%BE%93%E5%87%BA/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/06/11/C%E8%AF%AD%E8%A8%800%E9%95%BF%E5%BA%A6%E6%95%B0%E7%BB%84/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/06/11/C%E8%AF%AD%E8%A8%800%E9%95%BF%E5%BA%A6%E6%95%B0%E7%BB%84/" class="post-title-link" itemprop="url">C语言0长度数组</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-06-11 15:24:49" itemprop="dateCreated datePublished" datetime="2021-06-11T15:24:49+08:00">2021-06-11</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2021/06/11/C%E8%AF%AD%E8%A8%800%E9%95%BF%E5%BA%A6%E6%95%B0%E7%BB%84/" class="post-meta-item leancloud_visitors" data-flag-title="C语言0长度数组" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/06/11/C%E8%AF%AD%E8%A8%800%E9%95%BF%E5%BA%A6%E6%95%B0%E7%BB%84/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/06/11/C%E8%AF%AD%E8%A8%800%E9%95%BF%E5%BA%A6%E6%95%B0%E7%BB%84/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​     关于C语言中的0长度数组，被使用起来的话还是很妙的，下面的内容部分来自于互联网，参考了以下几篇博文：</p>
<p>​     <a target="_blank" rel="noopener" href="https://blog.csdn.net/zhaixuebuluo/article/details/86657929">https://blog.csdn.net/zhaixuebuluo/article/details/86657929</a> ，</p>
<p>​     <a target="_blank" rel="noopener" href="https://kernel.blog.csdn.net/article/details/64131322?utm_medium=distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromMachineLearnPai2~default-1.control&amp;depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromMachineLearnPai2~default-1.control">https://kernel.blog.csdn.net/article/details/64131322?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control&amp;depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control</a> 。</p>
<h3 id="1-什么是零长度数组"><a href="#1-什么是零长度数组" class="headerlink" title="1. 什么是零长度数组"></a>1. 什么是零长度数组</h3><p>​    零长度数组就是长度为0的数组(也叫柔性数组)，它不占用内存存储空间。零长度数组一般单独使用的机会很少，它常常作为结构体的一个成员，构成一个变长结构体。并且在结构体中，数组为0的数组必须在最后声明。</p>
<h3 id="2-零长度数组用途"><a href="#2-零长度数组用途" class="headerlink" title="2. 零长度数组用途"></a>2. 零长度数组用途</h3><p>​    我们以实际的例子来分析一下，为什么要使用零长度数组。考虑下面这个场景：比如说准备发送一个数据缓冲区里面的数据, 缓冲区包括一个len字段和data字段, 分别标识数据的长度和传输的数据。</p>
<h4 id="2-1-定长包"><a href="#2-1-定长包" class="headerlink" title="2.1 定长包"></a>2.1 定长包</h4><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//  定长缓冲区</span></span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">max_buffer</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">    <span class="keyword">int</span>     len;</span><br><span class="line">    <span class="keyword">char</span>    data[MAX_LENGTH];</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<p>​    <strong>数据结构的大小：</strong></p>
<p>​    考虑对齐, 那么数据结构的大小 &gt;= sizeof(int) + sizeof(char) * MAX_LENGTH</p>
<p>​    由于考虑到数据的溢出, data 数组长度一般会设置得足够长足以容纳最大的数据, 因此 max_buffer 中的data数组很多情况下都没有填满数据, 因此造成了浪费。</p>
<p>​    <strong>数据包构造：</strong></p>
<p>​    假如要发送 CURR_LENGTH = 1024个字节：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> ((mbuffer = (struct max_buffer *)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(struct max_buffer))) != <span class="literal">NULL</span>)</span><br><span class="line">&#123;</span><br><span class="line">    mbuffer-&gt;len = CURR_LENGTH;</span><br><span class="line">    <span class="built_in">memcpy</span>(mbuffer-&gt;data, <span class="string">&quot;Hello World&quot;</span>, CURR_LENGTH);</span><br><span class="line"></span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">&quot;%d, %s\n&quot;</span>, mbuffer-&gt;len, mbuffer-&gt;data);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>​    前部分 4 个字节 p-&gt;len, 作为包头，这个包头是用来描述紧接着包头后面的数据部分的长度，这里是 1024, 所以前四个字节赋值为 1024。而紧接其后的内存是真正的数据部分, 通过 p-&gt;data, 最后, 进行一个 memcpy()内存拷贝, 把要发送的数据填入到这段内存当中。</p>
<h4 id="2-2-指针数据包"><a href="#2-2-指针数据包" class="headerlink" title="2.2  指针数据包"></a>2.2  指针数据包</h4><p>​    如果将上面的长度为 MAX_LENGTH的定长数组换为指针, 每次使用时动态的开辟 CURR_LENGTH 大小的空间, 那么就避免造成 MAX_LENGTH - CURR_LENGTH空间的浪费, <strong>只浪费了一个指针域的空间</strong>。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">point_buffer</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">    <span class="keyword">int</span>     len;</span><br><span class="line">    <span class="keyword">char</span>    *data;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<p>​    <strong>数据结构的大小：</strong></p>
<p>​    考虑对齐, 那么数据结构的大小 &gt;= sizeof(int) + sizeof(char *)</p>
<p>​    <strong>数据包构造：</strong></p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> ((pbuffer = (struct point_buffer *)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(struct point_buffer))) != <span class="literal">NULL</span>)</span><br><span class="line">&#123;</span><br><span class="line">       pbuffer-&gt;len = CURR_LENGTH;</span><br><span class="line">       <span class="keyword">if</span> ((pbuffer-&gt;data = (<span class="keyword">char</span> *)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(<span class="keyword">char</span>) * CURR_LENGTH)) != <span class="literal">NULL</span>)</span><br><span class="line">       &#123;</span><br><span class="line">           <span class="built_in">memcpy</span>(pbuffer-&gt;data, <span class="string">&quot;Hello World&quot;</span>, CURR_LENGTH);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">           <span class="built_in">printf</span>(<span class="string">&quot;%d, %s\n&quot;</span>, pbuffer-&gt;len, pbuffer-&gt;data);</span><br><span class="line">       &#125;</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>
<ol>
<li><p>首先, 需为结构体分配一块内存空间;</p>
</li>
<li><p>其次再为结构体中的成员变量分配内存空间.</p>
<p><strong>这样两次分配的内存是不连续的, 需要分别对其进行管理</strong>. </p>
</li>
</ol>
<p>开辟空间时, 需要额外开辟数据域的空间, 释放时候也需要显示释放数据域的空间, 但是实际使用过程中, 往往在函数中开辟空间, 然后返回给使用者指向 struct point_buffer 的指针, 这时候我们并不能假定使用者了解我们开辟的细节, 并按照约定的操作释放空间, 因此使用起来多有不便, 甚至造成内存泄漏。</p>
<h4 id="2-3-变长数据缓冲区"><a href="#2-3-变长数据缓冲区" class="headerlink" title="2.3 变长数据缓冲区"></a><strong>2.3 变长数据缓冲区</strong></h4><p>​    定长数组使用方便, 但是却浪费空间, 指针形式只多使用了一个指针的空间, 不会造成大量空间分浪费, 但是使用起来需要多次分配, 多次释放。<strong>那有没有一种方法，即能够既不浪费空间, 又使用方便的呢?这就引出了0长度数组</strong>。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//  0长度数组</span></span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">zero_buffer</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">    <span class="keyword">int</span>     len;</span><br><span class="line">    <span class="keyword">char</span>    data[<span class="number">0</span>];</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<p>​    <strong>数据结构的大小：</strong></p>
<p>​    因为char data[0]只是个数组名, 是不占用存储空间的, 即sizeof(struct zero_buffer) = sizeof(int)。</p>
<p>​    <strong>数据包构造：</strong></p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">///  开辟</span></span><br><span class="line"><span class="keyword">if</span> ((zbuffer = (struct zero_buffer *)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(struct zero_buffer) + <span class="keyword">sizeof</span>(<span class="keyword">char</span>) * CURR_LENGTH)) != <span class="literal">NULL</span>)</span><br><span class="line">&#123;</span><br><span class="line">    zbuffer-&gt;len = CURR_LENGTH;</span><br><span class="line">    <span class="built_in">memcpy</span>(zbuffer-&gt;data, <span class="string">&quot;Hello World&quot;</span>, CURR_LENGTH);</span><br><span class="line"></span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">&quot;%d, %s\n&quot;</span>, zbuffer-&gt;len, zbuffer-&gt;data);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>​    这个程序中，我们使用malloc申请了一片内存，大小为：sizeof(struct zero_buffer) + sizeof(char) * CURR_LENGTH)。其中sizeof(char) * CURR_LENGTH)是我们真正使用的内存空间，我们可以通过结构体成员data，直接访问这片内存。</p>
<h3 id="3-补充：为什么不用指针代替0长度数组"><a href="#3-补充：为什么不用指针代替0长度数组" class="headerlink" title="3. 补充：为什么不用指针代替0长度数组"></a>3. 补充：为什么不用指针代替0长度数组</h3><p>​    数组名在作为函数参数进行参数传递时，就<strong>相当于</strong>是一个指针。在这里，我们千万别被这句话迷惑了：数组名在作为函数参数传递时，确实传递的是一个地址，<strong>但数组名绝不是指针，两者不是同一个东西</strong>。数组名用来表征一块连续内存存储空间的地址，而指针是一个变量，编译器要给它单独再分配一个内存空间，用来存放它指向的变量的地址。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/06/10/C%E8%AF%AD%E8%A8%80%E5%AE%9E%E7%8E%B0%E8%BF%9B%E5%BA%A6%E6%9D%A1%E5%92%8C%E8%BF%9E%E6%8E%A5%E7%AD%89%E5%BE%85%E6%95%88%E6%9E%9C/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/06/10/C%E8%AF%AD%E8%A8%80%E5%AE%9E%E7%8E%B0%E8%BF%9B%E5%BA%A6%E6%9D%A1%E5%92%8C%E8%BF%9E%E6%8E%A5%E7%AD%89%E5%BE%85%E6%95%88%E6%9E%9C/" class="post-title-link" itemprop="url">C语言实现进度条和连接等待效果</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-06-10 19:34:26" itemprop="dateCreated datePublished" datetime="2021-06-10T19:34:26+08:00">2021-06-10</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2021/06/10/C%E8%AF%AD%E8%A8%80%E5%AE%9E%E7%8E%B0%E8%BF%9B%E5%BA%A6%E6%9D%A1%E5%92%8C%E8%BF%9E%E6%8E%A5%E7%AD%89%E5%BE%85%E6%95%88%E6%9E%9C/" class="post-meta-item leancloud_visitors" data-flag-title="C语言实现进度条和连接等待效果" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/06/10/C%E8%AF%AD%E8%A8%80%E5%AE%9E%E7%8E%B0%E8%BF%9B%E5%BA%A6%E6%9D%A1%E5%92%8C%E8%BF%9E%E6%8E%A5%E7%AD%89%E5%BE%85%E6%95%88%E6%9E%9C/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/06/10/C%E8%AF%AD%E8%A8%80%E5%AE%9E%E7%8E%B0%E8%BF%9B%E5%BA%A6%E6%9D%A1%E5%92%8C%E8%BF%9E%E6%8E%A5%E7%AD%89%E5%BE%85%E6%95%88%E6%9E%9C/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    TI 15.4 stack linux端的开发包，里面有个cc13xx-sbl的例子，是串口升级协处理器代码的demo，里面的代码写的蛮好的，可以拿来学习。</p>
<h3 id="1-让printf打印出颜色"><a href="#1-让printf打印出颜色" class="headerlink" title="1.让printf打印出颜色"></a>1.让printf打印出颜色</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/C111apture.JPG" style="zoom:67%;">

<h3 id="2-连接东西等待的效果"><a href="#2-连接东西等待的效果" class="headerlink" title="2.连接东西等待的效果"></a>2.连接东西等待的效果</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Cap3433ture.JPG" style="zoom:67%;">

<p>​    为什么要加第12行这句代码，因为11行没有换行符，如果不加12行，会打印不出东西。(需要知道一个事实：标准输出是以“行”为单位进行的，也即碰到\n才打印数据到屏幕)这时候，fflush(stdout)就起到及时输出的作用。如果我强制在11行加换行符，结果等待的效果又不是自己想要的那样：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/错的情况连接.JPG" style="zoom:67%;">

<h3 id="3-进度条的效果"><a href="#3-进度条的效果" class="headerlink" title="3.进度条的效果"></a>3.进度条的效果</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/C222apture.JPG" style="zoom:67%;">

<p>​    我们用[]固定在左右两边，中间预留空间，然后用’=’进行填充在这里我们用”=”表示1%，通过增加字符来保证进度的增加。printf(“[%-100s]\r”,str); 格式化输出。’-‘表示左对齐 100表示列宽，’\r’表示回车，即每次打印完使光标回到行首。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/06/10/gstreamer%E8%AF%BB%E5%8F%96rtsp%E6%B5%81/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/06/10/gstreamer%E8%AF%BB%E5%8F%96rtsp%E6%B5%81/" class="post-title-link" itemprop="url">gstreamer读取rtsp流</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-06-10 19:24:49" itemprop="dateCreated datePublished" datetime="2021-06-10T19:24:49+08:00">2021-06-10</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jetson/" itemprop="url" rel="index"><span itemprop="name">Jetson</span></a>
                </span>
            </span>

          
            <span id="/2021/06/10/gstreamer%E8%AF%BB%E5%8F%96rtsp%E6%B5%81/" class="post-meta-item leancloud_visitors" data-flag-title="gstreamer读取rtsp流" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/06/10/gstreamer%E8%AF%BB%E5%8F%96rtsp%E6%B5%81/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/06/10/gstreamer%E8%AF%BB%E5%8F%96rtsp%E6%B5%81/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="1-创建rtsp视频流环境"><a href="#1-创建rtsp视频流环境" class="headerlink" title="1. 创建rtsp视频流环境"></a>1. 创建rtsp视频流环境</h2><p>​    在手机上下载IP摄像头软件，然后打开IP摄像头服务器。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210130134851.jpg" style="zoom:30%;">

<p>​    在RTSP服务器那边打勾就可以了，然后点击下面的分享，就可以看到rtsp流的地址。</p>
<h2 id="2-gstreamer读取流"><a href="#2-gstreamer读取流" class="headerlink" title="2. gstreamer读取流"></a>2. gstreamer读取流</h2><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">gst-launch<span class="number">-1.0</span> rtspsrc location=<span class="string">&quot;rtsp://admin:admin@192.168.0.5:8554/live&quot;</span> ! rtph264depay ! h264parse ! avdec_h264 ! nveglglessink</span><br></pre></td></tr></table></figure>
<p>​    效果如下图所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210130140326.jpg" style="zoom:40%;">
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/06/10/float%E5%BF%AB%E9%80%9F%E8%BD%ACint%E7%9A%84%E6%96%B9%E6%B3%95/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/06/10/float%E5%BF%AB%E9%80%9F%E8%BD%ACint%E7%9A%84%E6%96%B9%E6%B3%95/" class="post-title-link" itemprop="url">float快速转int的方法</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-06-10 16:10:10" itemprop="dateCreated datePublished" datetime="2021-06-10T16:10:10+08:00">2021-06-10</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2021/06/10/float%E5%BF%AB%E9%80%9F%E8%BD%ACint%E7%9A%84%E6%96%B9%E6%B3%95/" class="post-meta-item leancloud_visitors" data-flag-title="float快速转int的方法" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/06/10/float%E5%BF%AB%E9%80%9F%E8%BD%ACint%E7%9A%84%E6%96%B9%E6%B3%95/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/06/10/float%E5%BF%AB%E9%80%9F%E8%BD%ACint%E7%9A%84%E6%96%B9%E6%B3%95/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    原文来自于网络，地址为：<a target="_blank" rel="noopener" href="https://www.cnblogs.com/sdragonx/p/10933096.html">https://www.cnblogs.com/sdragonx/p/10933096.html</a> ，主要目的是提高float转int的效率。       </p>
<p>​    这边给出直接可以使用的代码，如下所示：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//四舍五入，处理的数据范围是-2^22 ~ 2^22-1, -4194304.0 ~ 4194303.0</span></span><br><span class="line"><span class="function"><span class="keyword">inline</span> <span class="keyword">int32_t</span> <span class="title">f_toint32</span><span class="params">(<span class="keyword">float</span> x)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">//取得符号位，设置掩码</span></span><br><span class="line">    <span class="keyword">uint32_t</span> n = ((*(<span class="keyword">uint32_t</span>*)&amp;x) &amp; <span class="number">0x80000000</span>) ? <span class="number">0xFFC00000</span> : <span class="number">0</span>;</span><br><span class="line">    x += <span class="number">12582912.0f</span>;</span><br><span class="line">    <span class="keyword">return</span> ((*(<span class="keyword">uint32_t</span>*)&amp;x) &amp; <span class="number">0x3FFFFF</span>) | n;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/21/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/21/">21</a><span class="page-number current">22</span><a class="page-number" href="/page/23/">23</a><span class="space">&hellip;</span><a class="page-number" href="/page/29/">29</a><a class="extend next" rel="next" href="/page/23/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
